package com.wanmait.wanmarecruit.manageController;

import com.wanmait.wanmarecruit.service.CompanyService;
import com.wanmait.wanmarecruit.service.PositionTypeService;
import com.wanmait.wanmarecruit.util.AjaxResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/manage")
public class ManageCompanyController {

    @Resource
    private CompanyService companyService;

    @Resource
    private PositionTypeService positionTypeService;

    @GetMapping("/companyList")
    public AjaxResult getAllCompanyList(Integer pageNum,String positionTypeId,String keyword)
    {
        System.out.println(pageNum+positionTypeId+keyword);
        if (pageNum==null)
        {
            pageNum=1;
        }
        Integer pageSize=5;
        return AjaxResult.success(companyService.selectAllCompany(pageNum,pageSize,positionTypeId,keyword));
    }
    @GetMapping("/getAllPositionType")
    public AjaxResult getAllPositionType()
    {
     return AjaxResult.success(positionTypeService.getAllPositionType());
    }

    @RequestMapping("updateCompanyEnableFalseByCompanyId")
    public AjaxResult updateCompanyEnableFalseByCompanyId(Integer companyId)
    {
        companyService.updateCompanyEnableFalseByCompanyId(companyId);
        return AjaxResult.success("您已成功将该公司封禁!");
    }
}
